<template>
  <div>
    <h3>
      人气推荐
      <i class="iconfont icon-bottom"></i>
    </h3>
    <ul>
      <li
        v-for="item in lists"
        :key="item.id"
        @click="
          $router.push({
            path: '/details',
            query: {
              id: item.id,
            },
          })
        "
      >
        <img :src="item.pic" alt="" />
        <p>{{ item.name }}</p>
        <p>{{ item.characteristic }}</p>
        <p>￥{{ item.minPrice }}</p>
      </li>
    </ul>
  </div>
</template>

<script>
  import { getRenqi } from "../utils/api/index"

  export default {
    data() {
      return {
        lists: [],
      }
    },
    created() {
      getRenqi().then((res) => {
        this.lists = res.data.splice(9, 4)
      })
    },
  }
</script>

<style lang="scss" scoped>
  h3 {
    text-align: center;
    font-size: 0.32rem;
    height: 0.8rem;
    line-height: 0.8rem;
  }
  img {
    display: block;
  }
  ul {
    padding: 0.2rem;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    li {
      width: calc(50% - 0.1rem);
      flex-shrink: 0;
      img {
        width: 100%;
        height: 4.4rem;
        margin-bottom: 0.2rem;
      }
      p {
        font-size: 0.28rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-bottom: 0.2rem;
        &:nth-of-type(2) {
          color: gray;
        }
        &:last-child {
          color: red;
        }
      }
    }
  }
</style>
